import React, {
  Component
} from 'react';
import {
  BrowserRouter as Router,
  Route
} from 'react-router-dom';
import Home from '../components/index/index.jsx'; // 首页
import Client from '../components/client/client.jsx'; // 客户
import Label from '../components/client/label/label.jsx'; //标签
import LabelTool from '../components/client/label/labelTool.jsx'; //标签管理
import ChangeClient from '../components/client/label/changeClient.jsx'; //选择客户
import Search from '../components/client/search/search.jsx'; //搜索
import Message from '../components/message/message.jsx'; // 消息
import MessageCont from '../components/message/messageCont.jsx'; // 聊天室
import Moments from '../components/moments/moments.jsx'; // 动态
import CompanyDynamic from '../components/moments/companyDynamic.jsx'; // 公司动态详情
import User from '../components/user/user.jsx'; // 我的
import PerfectCard from '../components/user/perfectCard.jsx'; // 完善名片信息
import WelcomeLag from '../components/user/welcomeLag.jsx'; // 欢迎语
import LabelMy from '../components/user/labelMy.jsx'; // 个性标签
import MyCard from '../components/user/myCard.jsx'; // 我的名片
import MyProduct from '../components/user/myProduct.jsx'; // 我的产品
import UploadPic from '../components/user/uploadPic.jsx'; // 上传图片
import ProductDefault from '../components/user/productCard/productDefault.jsx'; // 产品详情
import ClinetDetails from '../components/widget/clinetDetails/clinetDetails.jsx'; // 客户详情
import ClientNews from '../components/widget/clinetDetails/clientNews.jsx'; // 资料详情
import ClientLabel from '../components/widget/clinetDetails/clientLabel/clientLabel.jsx'; // 个性标签
import Report from '../components/user/report.jsx';
import ReportUserList from '../components/user/customerList.jsx';

let baseUrl = '/webEmployee'

const routes = [ // 构建全局路由
  {
    path: '/index', // 父路由
    component: Home
  }, {
    path: '/client',
    component: Client
  }, {
    path: '/client/label',
    component: Label
  }, {
    path: '/client/labeltool',
    component: LabelTool
  }, {
    path: '/client/labeltool/changeClient',
    component: ChangeClient
  }, {
    path: '/client/search',
    component: Search
  }, {
    path: '/message',
    component: Message
  }, {
  path: '/messageCont',
    component: MessageCont
  }, {
    path: '/moments',
    component: Moments
  }, {
    path: '/moments/companyDynamic',
    component: CompanyDynamic
  }, {
    path: '/user',
    component: User
  }, {
    path: '/user/perfectCard',
    component: PerfectCard
  }, {
    path: '/user/welcomeLag',
    component: WelcomeLag
  }, {
    path: '/user/labelMy',
    component: LabelMy
  }, {
    path: '/user/myCard',
    component: MyCard
  }, {
    path: '/user/myProduct',
    component: MyProduct
  }, {
    path: '/user/myProduct/productDefault',
    component: ProductDefault
  }, {
    path: '/user/uploadPic',
    component: UploadPic
  }, {
    path: '/clinetDetails',
    component: ClinetDetails
  }, {
    path: '/clinetDetails/clientNews',
    component: ClientNews
  }, {
    path: '/clinetDetails/clientLabel',
    component: ClientLabel
  }, {
    path: '/report',
    component: Report
  }, {
    path: '/customerList',
    component: ReportUserList
  }
]

const RouteWithSubRoutes = (route) => (
<Route path={baseUrl + route.path} exact render={props => (
    // pass the sub-routes down to keep nesting
      <route.component baseUrl={baseUrl} {...props} routes={route.routes} />
)
}
/>
)

// const getConfirmation = (message, callback) => {
//   const allowTransition = window.confirm(message)
//   // callback(allowTransition)
// }
export default class BasicExample extends Component {
  // constructor(props) {
  //   super(props)
  // }
  render() {
    return (
      <Router>
        <div className='main-content'>
          <div className='clearfix'>
            {
              routes.map((route, i) => (
                <RouteWithSubRoutes key={i} {...route}/>
              ))
            }
          </div>
        </div>
      </Router>
    )
  }
}